package cn.com.dpc.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import cn.com.dpc.R;

public class ImageAdapter extends BaseAdapter {
	private Context context;

	public ImageAdapter(Context context) {
		this.context = context;
	}

	public String[] className = {
			// 九宫格图片的设置
			"alarmSoundSet", "alarmLevelSet", "moreSet", "update", "about" };
	public Integer[] images = {
			// 九宫格图片的设置
			R.drawable.icon1, R.drawable.icon1, R.drawable.icon1,
			R.drawable.icon4, R.drawable.icon5 };

	public String[] texts = {
			// 九宫格图片下方文字的设置
			"告警声音设置", "告警等级设置", "其他设置", "帮助更新", "关于" };

	public int[] type = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

	// get the number
	@Override
	public int getCount() {
		return images.length;
	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	// get the current selector's id number
	@Override
	public long getItemId(int position) {
		return position;
	}

	// create view method
	@Override
	public View getView(int position, View convertView, ViewGroup viewgroup) {
		ImgTextWrapper wrapper;
		View view = null;
		wrapper = new ImgTextWrapper();
		LayoutInflater inflater = LayoutInflater.from(context);
		view = inflater.inflate(R.layout.item, null);
		view.setTag(wrapper);
		view.setPadding(15, 15, 15, 15); // 每格的间距

		wrapper.imageView = (ImageView) view
				.findViewById(R.id.MainActivityImage);
		wrapper.imageView.setBackgroundResource(images[position]);
		wrapper.textView = (TextView) view.findViewById(R.id.MainActivityText);
		wrapper.textView.setText(texts[position]);

		return view;
	}

	class ImgTextWrapper {
		public ImageView imageView;
		public TextView textView;
	}
}